<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div id="ev">
    <style>
      #ev {
        width: 300px;
        height: 100px;
        background: red;
        color: #fff;
        text-align: center;
        line-height: 100px;
      }
    </style>
    目标元素
  </div>
  <script>
    var ev = document.getElementById('ev');

    window.addEventListener("click", function () {
      console.log("捕获 window");
    }, true)

    document.addEventListener("click", function() {
      console.log("捕获 document");
    }, true);

    document.documentElement.addEventListener("click", function () {
      console.log("捕获 html");
    }, true);

    document.body.addEventListener("click", function () {
      console.log("捕获 body");
    }, true);

    ev.addEventListener("click", function () {
      console.log("捕获 ev");
    }, true);


    window.addEventListener("click", function () {
      console.log("冒泡 window");
    }, false);

    document.addEventListener("click", function() {
      console.log("冒泡 document");
    }, false);

    document.documentElement.addEventListener("click", function () {
      console.log("冒泡 html");
    }, false);

    document.body.addEventListener("click", function () {
      console.log("冒泡 body");
    }, false);

    ev.addEventListener("click", function () {
      console.log("冒泡 ev");
    }, false);

  </script>
</body>
</html>
